package cn.xu.liteflow;

import com.yomahub.liteflow.parser.el.ClassXmlFlowELParser;
import org.springframework.stereotype.Component;

/**
 * @Author xuguofei clark2021@qq.com || WX clark_2023
 * @Date 2024/3/13
 * @Desc TODO
 **/
public class TestCustomerParserFlowFileConfig extends ClassXmlFlowELParser {
    @Override
    public String parseCustom() {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<flow>");

        stringBuilder.append("<nodes>\n" +
                "        <node id=\"s1\" name=\"普通脚本1\" type=\"script\" language=\"java\">\n" +
                "            <![CDATA[\n" +
                "                    import cn.xu.liteflow.script.CommonT;\n" +
                "\n" +
                "                    import cn.xu.liteflow.components.Order;\n" +
                "                    import com.yomahub.liteflow.script.ScriptExecuteWrap;\n" +
                "                    import com.yomahub.liteflow.script.body.JaninoCommonScriptBody;\n" +
                "\n" +
                "                    import java.io.Serializable;\n" +
                "                    import java.util.HashMap;\n" +
                "                    import java.util.List;\n" +
                "                    import java.util.Map;\n" +
                "                    import java.util.concurrent.Callable;\n" +
                "\n" +
                "                    public class S1 implements JaninoCommonScriptBody {\n" +
                "                        @Override\n" +
                "                        public Void body(final ScriptExecuteWrap wrap) {\n" +
                "                            return CommonT.test(wrap, new Callable<Void>() {\n" +
                "                                @Override\n" +
                "                                public Void call() throws Exception {\n" +
                "                                    Order order = (Order)wrap.cmp.getContextBean(Order.class);\n" +
                "                                    System.out.println(order);\n" +
                "                                    Map<String, List<Serializable>> requestContextDataMap = (HashMap<String, List<Serializable>>)order.getRequestContextDataMap();\n" +
                "                                    List<Serializable> aaa = (List<Serializable>)requestContextDataMap.get(\"aaa\");\n" +
                "                                    System.out.println(aaa);\n" +
                "                                    return null;\n" +
                "                                }\n" +
                "                            });\n" +
                "                        }\n" +
                "                    }\n" +
                "\n" +
                "                ]]>\n" +
                "        </node>\n" +
                "    </nodes>");

        stringBuilder.append("<chain name=\"chain1\">\n" +
                "        THEN(a, b, c);\n" +
                "    </chain>");

//        stringBuilder.append("</flow>");
//
//        stringBuilder.append("<flow>");
        stringBuilder.append("<chain name=\"chain2\">\n" +
                "        SWITCH(sa).to(b, c);\n" +
                "    </chain>");

        stringBuilder.append("<chain name=\"chain12\">\n" +
                "        THEN(aContext, s1, bContext, c);\n" +
                "    </chain>");

        stringBuilder.append("</flow>");
        return stringBuilder.toString();
    }
}
